package com.itlong.cloud.enumerate;

import lombok.Getter;

/**
 * <desc>
 * 物业账单缴费类型.
 * </desc>
 *
 * @createDate 2018-08-14
 */
public enum BillTypeEnum {

    METER_EXPENSES("抄表费、物业费",1),
    SERVICE_EXPENSES("维修费",2),
    PARK_EXPENSES("停车费",3),
    MOON_CARD_EXPENSES("月卡缴费",4),
    TEMPORARY_PASSAGE_EXPENSES("临时通行费",5);

    @Getter
    private Integer type;  //物业账单缴费类型

    @Getter
    private String description;  //物业账单缴费类型描述（名称）


    /**
     * <desc>
     * 构造函数.
     * </desc>
     *
     * @param type        物业账单缴费类型
     * @param description 物业账单缴费类型描述（名称）
     * @author Qiang.S
     * @createDate 2018-08-14
     */
    BillTypeEnum(String description, Integer type) {
        this.description = description;
        this.type = type;
    }


    /**
     * <desc>
     * 根据物业账单缴费类型获取描述（名称）.
     * </desc>
     *
     * @param type 物业账单缴费类型
     * @return 物业账单缴费类型描述（名称）
     * @author Qiang.S
     * @createDate 2018-08-14
     */
    public static String getDescription(int type) {
        BillTypeEnum[] types = BillTypeEnum.values();
        for (BillTypeEnum limitCategory : types) {
            if (limitCategory.getType() == type) {
                return limitCategory.getDescription();
            }
        }
        return "";
    }


    /**
     * <desc>
     * 根据物业账单缴费类型（名称）获取类型.
     * </desc>
     *
     * @param description 物业账单缴费类型描述（名称）
     * @return 物业账单缴费类型
     * @author Qiang.S
     * @createDate 2018-08-14
     */
    public static Integer getType(String description) {
        BillTypeEnum[] types = BillTypeEnum.values();
        for (BillTypeEnum limitCategory : types) {
            if (limitCategory.getDescription().equalsIgnoreCase(description)) {
                return limitCategory.getType();
            }
        }
        return METER_EXPENSES.getType();
    }
}
